from src.data import DataSeq
import time

def SelectionSort(ds,v):
    assert isinstance(ds, DataSeq), "Type Error"

    Length = ds.length
    for i in range(Length):
        for j in range(i, Length):
            if ds.data[j] < ds.data[i]:
                ds.Swap(i, j)
            time.sleep(v)


def create_sort(title, v, l):
    ds = DataSeq(l, sort_title=title)
    ds.Visualize()
    ds.StartTimer()
    SelectionSort(ds, v)
    ds.StopTimer()
    ds.SetTimeInterval(0)
    # ds.Visualize()
    # print("准备退出")
    time.sleep(3)
    ds.destory()
    return 0

if __name__ == "__main__":
    create_sort("123",float(0.5),20)
    # ds = DataSeq(64)
    # ds.Visualize()
    # ds.StartTimer()
    # SelectionSort(ds)
    # ds.StopTimer()
    # ds.SetTimeInterval(0)
    # ds.Visualize()
